Skip to content

Conversation

@LordAbhishek
Copy link
Contributor

Backport
This is manual backport PR due to failure of backport assistance to cherry-pick the commit from main.
Original PR: #4788 to be included in release 1.8.x

The below text is copied from the body of the original PR.

Changes proposed in this PR
Added -capture flag to proxy log command.
This will enable user to capture log for given duration and write them to a file in current working dir.
If -update-level flag is provided along with -capture flag, it will set given new log level, capture the log for given duration and reset the log level to existing one post log capture.
consul-k8s proxy log -capture 1m -update-level debug

Signal interrupt handling:
Here, with existing base command setup, if signal interrupt is received during log capture, it would exit the terminal at an instant, so log levels won't be reset back to existing levels.
So, to handle the signal interrupt while capturing log, I have modified main.go, commands.go, common/base.go which will handle signal interrupts with the help of a cleanupReqAndCompleted channel for any cli command in consul-k8s.
With the new setup of common/base.go and main.go, it will reset back the log levels back to previous one, basically main will wait unitll reset.

* feat: add new `-capture` flag to proxy loglevel cmd

* feat: `proxy log <podname> -capture 30s` cmd will capture the log and write logs to a file

* feat: `proxy log <podname> -capture 30s -update-level warning` cmd will capture the log with provided envoy log level (warning), write logs to a file and reset envoy log level back to existing levels

* feat: modified cli/main.go, cli/command.go and cli/common/base.go to support graceful handle signal interrupts for any commands.

* adding the changelog

* Revert "adding the changelog"

This reverts commit 7a57d43.

* adding correct changelog

* minor changes

* minor code fixes and refactored fetchOrSetLogLevels to accept level as parameter

* updated changelog

* updated signal handling logic and code to use single channel

* merged all const in a single block

* Apply suggestions from code review

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Sriram R <[email protected]>
Co-authored-by: Copilot <[email protected]>
@LordAbhishek LordAbhishek added area/cli CLI pr/no-backport signals that a PR will not contain a backport label labels Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI pr/no-backport signals that a PR will not contain a backport label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant